package main.model.hexisland.tile;


public class TileTree
        extends AbstractTile
        implements Tile {
	
	private static final int TREEMAX = 2000;
	private int tree = TREEMAX;


    public static int getTreeMax(){
        return TREEMAX;
    }

	public TileTree(){
		
	}
	
	public TileTree(int tree){
		this.tree = tree;
		setTree(0);
	}
	
	private void setTree(int treeup){
		tree = tree + treeup;
		if(tree > TREEMAX){tree = TREEMAX;}
		else if(tree < 0){tree = 0;}
	}
	public int getTree(){
		return tree;
	}

	
	@Override
	public TileType getType(){
		return TileType.TREE;
	}
	@Override
	public int eat(){
		if(tree > 0){
			setTree(-40);
			return 40;
		}
		else{
			return 20;
		}
	}

	@Override
	public int tastyLook(){
		return tree+20;
	}
	@Override
	public void dayPass(){
		setTree(80);
	}

    @Override
    public boolean hasCentralObstacle() {
        return true;
    }

    @Override
    public boolean isAccessible() {
        return true;
    }


    public boolean equals(Object obj){
        if(obj == this) return true;
        if(!(obj instanceof TileTree)) return false;
        else{
            TileTree treeObj = (TileTree)obj;
            if(treeObj.getTree() == this.getTree()) return true;
            else return false;
        }
    }

    public String toString(){
        return getType().toString()+" ("+this.getTree()+")";
    }

    public int hashCode(){
        return this.toString().hashCode();
    }

}
